Skip to content

fix(smtp): strip a folded Bcc header from the outgoing DATA - #294

Merged
robert-virkus merged 1 commit into
Enough-Software:mainfrom
hobleyd:fix/smtp-strip-folded-bcc-header
Sep 29, 2026
Merged

robert-virkus merged 1 commit into
Enough-Software:mainfrom
hobleyd:fix/smtp-strip-folded-bcc-header

Conversation

@hobleyd

@hobleyd hobleyd commented Sep 29, 2026

Copy link
Copy Markdown

SmtpSendMailCommand and SmtpSendMailDataCommand remove the Bcc header from the DATA with ^Bcc:.*\r\n, which matches only the first physical line. Header.render folds any value longer than MailConventions.textLineMaxLength onto \r\n\t-prefixed continuation lines, and three or four display-named addresses are enough to cross that. Everything after the first line therefore stayed in the message, so every To/Cc recipient received the rest of the Bcc list.

This makes the pattern consume the continuation lines too:

^Bcc:.*\r\n(?:[ \t].*\r\n)*

The envelope was never affected: recipientAddresses already includes bcc, so Bcc recipients were delivered to. Only the header leaked.

Test: builds a message whose Bcc header folds, and checks the command's DATA has no Bcc line, no continuation line and none of the hidden addresses, while To, Cc, Subject and body survive.

SmtpSendMailCommand and SmtpSendMailDataCommand removed the Bcc header
with `^Bcc:.*\r\n`, which only matches the first physical line. Header.render
folds any value longer than MailConventions.textLineMaxLength onto
`\r\n\t`-prefixed continuation lines, which three or four addresses already
do, so everything after the first line stayed in the DATA and every To/Cc
recipient received the rest of the Bcc list.

The pattern now consumes the continuation lines as well. The envelope was
never affected: recipientAddresses already includes bcc.
@robert-virkus

Copy link
Copy Markdown
Member

Good find, thanks again, David!

@robert-virkus
robert-virkus merged commit 750539f into Enough-Software:main Sep 29, 2026
1 check passed
marcov-dart pushed a commit to marcov-dart/enough_mail that referenced this pull request Oct 6, 2026
…er section

The folded-Bcc fix from Enough-Software#294 only covered the DATA command; the BDAT
command, which MailClient prefers whenever a server announces CHUNKING,
still matched a single physical line and leaked every folded Bcc
recipient to all other recipients. Both paths now share removeBccHeader,
which matches the header name case-insensitively and never touches the
body, so a body line starting with 'Bcc:' is no longer removed.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants